#Mouahaha ca poutre !

class ClassParsor
  attr_reader :task_task, :task_time
  
  def initialize(file)
    @task_task = Hash.new
    @task_time = Hash.new

    if File.readable?(file)
      fd = File.open(file,'r')
      
      side = 0 #Define if parse task/during or task/task
      r_count = 0 #get size of instruction for each kind of instruction
      counter = 0 #index of task_task table
      while line = fd.gets
        if !/(.)[ ](.)/.match(line)
         r_count = line
          side = side + 1
        else
          if side == 1
            @task_time[line.split(" ")[0]] = line.split(" ")[1]
          else
            @task_task[counter] = Hash[line.split(" ")[0] => line.split(" ")[1]]
            counter = counter + 1
          end
        end
      end
    end
    @task_time.sort()
  end
  
  def debug
    #__DEBUG__
    puts "Nombre de taches : "
    puts @task_time.length
    puts "\n"
    puts @task_time.inspect
    puts "\n"
    puts "Nombre de dependances : "
    puts @task_task.length
    puts "\n"
    puts @task_task.inspect
    #__/DEBUG__
  end    
end

